package com.dev.utils.app.helper;

import com.dev.utils.app.ListenerUtils;
import com.dev.utils.app.TextViewUtils;
import com.dev.utils.app.ViewUtils;
import ohos.agp.components.Component;
import ohos.agp.components.Text;

/**
 * detail: View 链式调用快捷设置 Helper 类
 * @author Ttt
 * <pre>
 *     通过 DevApp 工具类快捷实现
 *     <p></p>
 *     DevApp Api
 *     @see <a href="https://github.com/afkT/DevUtils/blob/master/lib/DevApp/README.md"/>
 * </pre>
 */
public class ViewHelper {

    // ViewHelper
    private static final ViewHelper HELPER = new ViewHelper();

    /**
     * 获取单例 ViewHelper
     * @return {@link ViewHelper}
     */
    public static ViewHelper get() {
        return HELPER;
    }

    // ==========
    // = Helper =
    // ==========

    /**
     * 获取 ViewHelper
     * @return {@link ViewHelper}
     */
    public ViewHelper viewHelper() {
        return HELPER;
    }

    /**
     * 设置 View 是否选中
     * @param selected {@code true} 选中, {@code false} 非选中
     * @param views    Component[]
     * @return {@code true} 选中, {@code false} 非选中
     */
    public ViewHelper setSelected(
            final boolean selected,
            final Component... views
    ) {
        ViewUtils.setSelected(selected, views);
        return this;
    }

    /**
     * 设置 TextView 是否加粗
     * @param view   {@link Text}
     * @param isBold {@code true} yes, {@code false} no
     * @return {@link ViewHelper}
     */
    public ViewHelper setBold(
            final Component view,
            final boolean isBold
    ) {
        TextViewUtils.setBold(view, isBold);
        return this;
    }

    /**
     * 设置字体颜色
     * @param view  {@link Text}
     * @param color R.color.id
     * @return {@link ViewHelper}
     */
    public ViewHelper setTextColor(
            final Component view,
            final int color
    ) {
        TextViewUtils.setTextColor(view, color);
        return this;
    }

    public ViewHelper setTextSize(
            final  Component view,
            final  int size
    ){
        TextViewUtils.setTextSize(view, Text.TextSizeType.PX,size);
        return this;
    }

    /**
     * 设置 Padding 边距
     * @param view    {@link Component}
     * @param padding Padding
     * @return {@link ViewHelper}
     */
    public ViewHelper setPadding(
            final Component view,
            final int padding
    ) {
        ViewUtils.setPadding(view, padding);
        return this;
    }

    /**
     * 设置 Padding 边距
     * @param view   {@link Component}
     * @param left   Left Padding
     * @param top    Top Padding
     * @param right  Right Padding
     * @param bottom Bottom Padding
     * @return {@link ViewHelper}
     */
    public ViewHelper setPadding(
            final Component view,
            final int left,
            final int top,
            final int right,
            final int bottom
    ) {
        ViewUtils.setPadding(view, left, top, right, bottom);
        return this;
    }


    /**
     * 设置背景颜色
     * @param view  {@link Component}
     * @param color 背景颜色
     * @return {@link ViewHelper}
     */
    public ViewHelper setBackgroundColor(
            final Component view,
            final int color
    ) {
        ViewUtils.setBackgroundColor(view, color);
        return this;
    }

    /**
     * 设置 View 显示的状态
     * @param isVisibility {@code true} View.VISIBLE, {@code false} View.GONE
     * @param view         {@link Component}
     * @return {@link ViewHelper}
     */
    public ViewHelper setVisibility(
            final boolean isVisibility,
            final Component view
    ) {
        ViewUtils.setVisibility(isVisibility, view);
        return this;
    }

    /**
     * 设置点击事件
     * @param onClickListener {@link Component.ClickedListener}
     * @param views           View 数组
     * @return {@link ViewHelper}
     */
    public ViewHelper setOnClicks(
            final Component.ClickedListener onClickListener,
            final Component... views
    ) {
        ListenerUtils.setOnClicks(onClickListener, views);
        return this;
    }


}

